<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script>
		let star = {
			name: '张XX',
			age: 25,
			phone: '13910733521'
		}
		let agent = new Proxy(star, {
			get: function(target, key) {
				if(key === 'phone') {
					//返回经纪人自己的手机号
					return '18611112222'
				}
				if(key === 'price') {
					//明星不报价，经纪人报价
					return 120000
				}
				return target[key]
			},
			set: function(target, key, val) {
				if(key === 'customPrice') {
					if(val < 100000) {
						//最低10W
						throw new Error('报价太低')
					} else {
						target[key] = val
						return true
					}
				}
			}
		})
	</script>

</html>